package com.chenwut.stringDemo;

import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        String rightname = "zhangsan";
        String rightpassword = "123456";
        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名");
            String name = sc.next();
            System.out.println("请输入密码");
            String password = sc.next();

            if (name.equals(rightname) && password.equals(rightpassword)) {
                System.out.println("登录成功");
                break;
            } else {
                if(i == 2){
                    System.out.println("账号"+name+"已锁定，请联系后台xxx-xxxxxxxx");
                }else{
                    System.out.println("登陆失败，用户名或密码错误,剩余次数为"+(2 - i) +"次");
                }
            }
        }

    }
}
